<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="clock">
        <span></span>时<span></span>分 <span></span>秒
    </div>
    <script>
       window.onload = function (){
	var oClock = document.getElementById("clock");	
	var aSpan = oClock.getElementsByTagName("span");
	setInterval(getTimes, 1000);
	getTimes();
	function getTimes (){
		var oDate = new Date();
		var aDate = [oDate.getHours(), oDate.getMinutes(), oDate.getSeconds()];
		for (var i in aDate) aSpan[i].innerHTML = format(aDate[i])
	}
	function format(a){
		return a.toString().replace(/^(\d)$/, "0$1")
	}
}
    </script>
</body>
</html>